<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Mod_videos extends CI_Controller {

    private $mIdcat1 = array();
    private $mIdcat2 = array();
    private $mIdcat3 = array();
    private $daotac = array();
    private $datanew = array();
    private $per_page = '';
    private $total_rows = 6;
    private $uri_page = '';
    private $base_page = '';
    private $uri_segment = '';
    private $thongbao = '';
    function __construct() {
        parent::__construct();
        if($this->session->userdata('ngonngu') && $this->session->userdata('ngonngu')=='_en') {
            $this->rear = '_en';
            $this->lang->load('atta','english');
        }
        else{
            $this->rear = '';
            $this->lang->load('atta','vietnam');
        } 
    }

    function index() {
        $offset = $this->uri->segment(2);
        $this->per_page = 24;
        $this->base_page = $this->uri->segment(1) . '/';
        $this->uri_segment = 2;
        $dat['videos'] = $this->common_model->getdata('video',array('publish'=>1),'',array('id','DESC'),array($this->per_page, $offset));
        $this->total_rows = $this->common_model->getnumber2('video',array('publish'=>1));
        $this->phantrang();
        $dat['rear'] = $this->rear;
        $data['content'] = $this->load->view('mod_videos/views_videos.php',$dat,true);
        $this->load->view('index',$data);
    }

    function details() {
        $dat['rear'] = $this->rear;
        $id_videos = str_replace('id-','',$this->uri->segment(2));
        $dat['videos'] = $this->common_model->getone('video',array('id'=>$id_videos));
        $data['content'] = $this->load->view('mod_videos/views_videos_details.php',$dat,true);
        $this->load->view('index',$data);
    }

    function phantrang() {
        $this->load->library('pagination');
        $config['base_url'] = base_url() . $this->base_page;
        $config['total_rows'] = $this->total_rows;
        $config['per_page'] = $this->per_page;
        $config['uri_segment'] = $this->uri_segment;
        $config['num_links'] = 12;
        $this->pagination->initialize($config);
    }

}
